package logic

import (
	"context"
	"merchantmanager/merchantrpc/internal/svc"
	"merchantmanager/merchantrpc/merchantrpc"
	"merchantmanager/models/mysql"

	"github.com/zeromicro/go-zero/core/logx"
)

type MerchantAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMerchantAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MerchantAddLogic {
	return &MerchantAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *MerchantAddLogic) MerchantAdd(in *merchantrpc.MerchantRequest) (*merchantrpc.MerchantResponse, error) {
	// todo: add your logic here and delete this line
	mer := mysql.Mer{
		Name: in.Name,
		Stu:  in.Stu,
	}
	mysql.DB.Debug().Create(&mer)
	return &merchantrpc.MerchantResponse{
		Id: int64(mer.ID),
	}, nil
}
